/*
 * Created on 2006-2-21
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.csg.vap.bean.NetworkCfgOut;
import cn.com.sbell.vss.csg.vap.bean.NetworkCfgOut.Ethernet;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

/**
 * @author liang.a.chen
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GetVsIpInfo extends ProtectedVsCommander {

	protected Element executeCommand(VsClient vsClient, PropertiesHolder holder, Element root) {
		NetworkCfgOut netCfg = vsClient.getNetworkInfo();
//		changed by vondart: netCfg
		Ethernet[] ethernet = netCfg.getEthernet();
		for(int i=0;ethernet!=null && i<1;i++){
			Element net = root.addElement("ethernet");
			net.addElement("netId").addText(toString(ethernet[i].getNetId()));
			net.addElement("ipAddress").addText(toString(ethernet[i].getIpAddress()));
			net.addElement("subnetMask").addText(toString(ethernet[i].getNetMask()));
			net.addElement("port").addText(toString(ethernet[i].getPort()));
		}
		String[] dns = netCfg.getDns();
		for(int i=0;dns!=null && i<dns.length;i++){
			root.addElement("dns").addText(toString(dns[i]));
		}
		String[] gateway = netCfg.getGateway();
		for(int i=0;gateway!=null && i<gateway.length;i++){
			root.addElement("gateway").addText(toString(gateway[i]));
		}
//++++++++++++++++++++++++++++++++++++++++++++++
//		changed by vondart
//++++++++++++++++++++++++++++++++++++++++++++++
		root.addElement("netMode").addText(toString(netCfg.getNetMode()));
		root.addElement("bandwidth").addText(toString(netCfg.getBandwidth()));
		root.addElement("connectionMode").addText(toString(netCfg.getConnectionMode()));
		return root;
	}
}
